home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_3.lha / 7_3 / 7_3c.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  78 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / exercise 7.3
  6. undef line    /* DELETE */
  7. include <math.h>
  8. lass circle: public shape
  9.  
  10.    point center;
  11.    int radius;
  12.  
  13. ublic:
  14.    circle(point a, int r)
  15.    {
  16. center = a; radius = r;
  17.    }
  18.  
  19.    circle(point a, point b)
  20.    {
  21. center = a;
  22. radius = (int) sqrt((a.x - b.x) * (a.x - b.x) +
  23.             (a.y - b.y) * (a.y - b.y));
  24.    }
  25.  
  26.    void move(int a, int b)
  27.    {
  28. center.x += a;
  29. center.y += b;
  30.    }
  31.  
  32.    void draw();
  33.  
  34.    point north()
  35.    {
  36. return point(center.x + radius, center.y);
  37.    }
  38.  
  39.    point south()
  40.    {
  41. return point(center.x - radius, center.y);
  42.    }
  43.  
  44.    point east()
  45.    {
  46. return point(center.x, center.y + radius);
  47.    }
  48.  
  49.    point west()
  50.    {
  51. return point(center.x, center.y - radius);
  52.    }
  53.  
  54.    point neast()
  55.    {
  56. return point(center.x + radius,
  57.          center.y + radius);
  58.    }
  59.  
  60.    point nwest()
  61.    {
  62. return point(center.x - radius,
  63.          center.y + radius);
  64.    }
  65.  
  66.    point seast()
  67.    {
  68. return point(center.x - radius,
  69.          center.y + radius);
  70.    }
  71.  
  72.    point swest()
  73.    {
  74. return point(center.x - radius,
  75.          center.y - radius);
  76.    }
  77. ;
  78.